<template>
	<view>
		<view class="main1">
			<view @click="showHome(0)" :class="[{'item_choice':item_choice == 0},{'main1_item':item_choice !=0}]">用户信息
			</view>
			<view @click="add(1)" :class="[{'item_choice':item_choice == 1},{'main1_item':item_choice !=1}]">发布推广信息
			</view>
			<view @click="add(2)" :class="[{'item_choice':item_choice == 2},{'main1_item':item_choice !=2}]">发布渠道信息
			</view>
			<view @click="add(3)" :class="[{'item_choice':item_choice == 3},{'main1_item':item_choice !=3}]">发布新帖
			</view>
			<view @click="show(4)" :class="[{'item_choice':item_choice == 4},{'main1_item':item_choice !=4}]">
				我的产品信息 <view style="color: #FF0000;">({{cp_size}}条）</view>
			</view>
			<view @click="show(5)" :class="[{'item_choice':item_choice == 5},{'main1_item':item_choice !=5}]">我的渠道信息
				<view style="color: #FF0000;">({{qd_size}}条）</view>
			</view>
			<view @click="show(6)" :class="[{'item_choice':item_choice == 6},{'main1_item':item_choice !=6}]">我的帖子
				<view style="color: #FF0000;">({{tz_size}}条）</view>
			</view>
			<view @click="show(7)" :class="[{'item_choice':item_choice == 7},{'main1_item':item_choice !=7}]">我的回复
			<view style="color: #FF0000;">({{hf_size}}条）</view>
			</view>
			<view @click="show(8)" :class="[{'item_choice':item_choice == 8},{'main1_item':item_choice !=8}]">消息回复
			<view style="color: #FF0000; font-size: 20px;">(今天{{shoudao_hf_tody_size}}条）</view>
			</view>
			<view @click="show(9)" :class="[{'item_choice':item_choice == 9},{'main1_item':item_choice !=9}]">修改密码
			</view>
		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				item_choice: 0,
				cp_size: 0,
				qd_size: 0,
				tz_size: 0,
				hf_size:0,
				shoudao_hf_all_size:0,
				shoudao_hf_tody_size:0,
			}
		},
		
		mounted() {
			uni.$on('updateSize', (res) => {
				
				this.getSize();
			})
			this.getSize();

		},
		methods: {

			showHome(index) {
				this.item_choice = index;
			},
			add(index) {
				this.item_choice = index;
				uni.$emit('itemClick', index);
				console.log("add", index);
			},
			show(index) {
				this.item_choice = index;
				uni.$emit('itemClick', index);
			},
			getSize() {
				this.getCpSize();
				this.getqdSize();
				this.getTzSize();
				this.gethfSize();
				this.getReviceSize();
			},

			async getCpSize() {
				try {
					const res = await this.$getData({
						url: this.$apis.getChanPingSizeForUser,
						data: {
							userId: this.$PublicData.getUserdata().uid,
						}
					})
					this.cp_size = res.data.data;

				} catch (e) {
					console.log("eee: ", e);
				}
			},
			async getqdSize() {
				try {
					const res = await this.$getData({
						url: this.$apis.getqdSizeForUser,
						data: {
							userId: this.$PublicData.getUserdata().uid,
						}
					})
					this.qd_size = res.data.data;

				} catch (e) {
					console.log("eee: ", e);
				}
			},
			async getTzSize() {
				try {
					const res = await this.$getData({
						url: this.$apis.getUserTzSizes,
						data: {
							userId: this.$PublicData.getUserdata().uid,
						}
					})
					this.tz_size = res.data.data;

				} catch (e) {
					console.log("eee: ", e);
				}
			},
			async gethfSize() {
				try {
					const res = await this.$getData({
						url: this.$apis.getMyHfSize,
						data: {
							userId: this.$PublicData.getUserdata().uid,
						}
					})
					this.hf_size = res.data.data;
			
				} catch (e) {
					console.log("eee: ", e);
				}
			},
			
			
			async getReviceSize() {
				try {
					const res = await this.$getData({
						url: this.$apis.getReviceHfTodySize,
						data: {
							userId: this.$PublicData.getUserdata().uid,
						}
					})
					this.shoudao_hf_tody_size = res.data.data;
			
				} catch (e) {
					console.log("eee: ", e);
				}
			},



		}
	}
</script>

<style>
	.main1 {

		width: 200px;
		height: 1000px;
		border: 1px solid #E5E5E5;
		display: flex;
		flex-direction: column;
	}

	.main1_item {
		align-items: center;
		height: 50px;
		width: 100%;
		display: flex;
		justify-content: center;
		border-bottom: 1px solid #E5E5E5;
	}

	.item_choice {
		align-items: center;
		min-height: 50px;
		width: 100%;
		display: flex;
		justify-content: center;
		border-bottom: 1px solid #E5E5E5;
		color: #FFFFFF;
		background: #F99B15;
	}
</style>
